﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;

namespace Modules.SMS.Entitys
{
    [TableName("sms_send_log")]
    [Description("短信发送日志")]
    [PrimaryKey("msg_id", AutoIncrement = false)]
    [CacheSetting(true, PropertyNamesOfArea = "Phone")]
    [Serializable]
    public class SmsSendLog : IEntity
    {
        /// <summary>
        ///
        ///</summary>
        [Column("msg_id")]
        public string MsgId { get; set; }

        /// <summary>
        /// 手机号码
        ///</summary>
        [Column("phone")]
        public string Phone { get; set; }

        /// <summary>
        /// 消息类型 (1:验证码 2.....)
        ///</summary>
        [Column("msg_type")]
        public MsgType MsgType { get; set; }

        /// <summary>
        /// 消息内容
        ///</summary>
        [Column("msg_content")]
        public string MsgContent { get; set; }

        /// <summary>
        /// 状态(1:发送成功  0:发送失败)
        ///</summary>
        [Column("status")]
        public int Status { get; set; }

        /// <summary>
        /// 验证码
        ///</summary>
        [Column("verification_code")]
        public string? VerificationCode { get; set; }

        /// <summary>
        /// 返回内容
        ///</summary>
        [Column("result_msg")]
        public string ResultMsg { get; set; }

        /// <summary>
        /// 是否已使用
        /// </summary>
        [Column("is_used")]
        public bool IsUsed { get; set; }

        /// <summary>
        /// 发送时间
        ///</summary>
        [Column("create_time")]
        public DateTime? CreateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 扩展字段
        /// </summary>
        [Column("extend1")]
        public string? Extend1 { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.MsgId; } }

        #endregion IEntity 成员
    }
}